Skip to content

test: migrate math/base/special/cphasef to ULP-based assertions - #14362

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-cphasef
Aug 17, 2026
Merged

test: migrate math/base/special/cphasef to ULP-based assertions#14362
kgryte merged 1 commit into
developfrom
kgryte/ulp-cphasef

Conversation

@kgryte

@kgryte kgryte commented Aug 17, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for math/base/special/cphasef from relative tolerance testing to ULP difference testing, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol computations in the fixture loops of test/test.js and test/test.native.js with t.strictEqual( isAlmostSameValue( actual, expected[ i ], N ), true, 'returns expected value' );.
  • adds the @stdlib/number/float32/base/assert/is-almost-same-value require (the single-precision variant, matching the idiom already used for other *f packages, e.g. math/base/special/atan2f and math/base/special/rad2degf) and removes the now-unused @stdlib/math/base/special/absf and @stdlib/constants/float32/eps requires.

Only the two test files are modified; no fixtures, implementations, or other packages are touched.

ULP bounds

The following bounds are the measured minimum for each fixture set. Each was found by computing the exact ULP distance between the returned and expected value for every fixture point, and then confirmed by re-running the suite at N - 1 (which fails):

Fixture Points ULP N - 1 result
positive_positive.json 5001 2 56 failing assertions at N = 1
negative_positive.json 1001 1 failing assertions at N = 0
negative_negative.json 1001 1 failing assertions at N = 0

The same three bounds hold for both the JavaScript and the native (C) implementation, so test.js and test.native.js use identical values. The two implementations do return differing values for a small number of fixture points (27 / 2 / 2 respectively), but in every such case both results remain within the bounds above, so no separate C-specific tolerances are required.

The previous relative tolerances were 1.3 * EPS for positive_positive and EPS for the other two fixture sets, which is consistent with the 2 / 1 / 1 ULP bounds above.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Verification performed:

  • make test TESTS_FILTER=".*/math/base/special/cphasef/.*" passes: 7052 assertions in test/test.js and 7052 in test/test.native.js, 0 failing. The native add-on was built locally, so test.native.js was actually executed rather than skipped.
  • The suite was run repeatedly at the final ULP values with identical results, to rule out FMA/architecture-dependent flakiness.
  • ESLint is clean for both files using etc/eslint/.eslintrc.tests.js.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored by Claude Code running as an unattended scheduled task. The agent studied the already-merged conversions for math/base/special/cphase, math/base/special/atan2f, and math/base/special/rad2degf in order to mirror the established idiom, applied the equivalent edits here, measured the minimum ULP bounds empirically over the full fixture set, and verified the result by building the native add-on and running both test files under make test.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance comparisons in the `cphasef` fixture loops
with ULP difference assertions via
`@stdlib/number/float32/base/assert/is-almost-same-value`, using the
minimum ULP bound which passes over the full fixture set.

Ref: #11352

Co-Authored-By: Claude <noreply@anthropic.com>

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality. labels Aug 17, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 17, 2026
@kgryte
kgryte marked this pull request as ready for review August 17, 2026 22:29
@kgryte
kgryte requested a review from a team August 17, 2026 22:29
@kgryte
kgryte merged commit dc8266d into develop Aug 17, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-cphasef branch August 17, 2026 22:30
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants